package com.scrapy.http.body;

import java.io.Serializable;
import java.net.URL;
import java.util.Date;
import java.util.List;

/**
 * 对网页信息的封装
 * @author 王碧林
 *
 */
public class HttpBody implements Serializable {

	/**
	 * 序列号的标志
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * 对url地址封装
	 */
	private URL url;
	/**
	 * 对当前页面上所以的页面链接进行的封装
	 */
	private List<String> urlsList;
	/**
	 * 当前页面上的html内容
	 */
	private String countxt;
	/**
	 * 当前页面爬下来的时间
	 */
	private Date date;

	public HttpBody() {
	}

	public HttpBody(URL url, List<String> urlsList, String countxt, Date date) {
		this.url = url;
		this.urlsList = urlsList;
		this.countxt = countxt;
		this.date = date;
	}

	public URL getUrl() {
		return url;
	}

	public void setUrl(URL url) {
		this.url = url;
	}

	public List<String> getUrlsList() {
		return urlsList;
	}

	public void setUrlsList(List<String> urlsList) {
		this.urlsList = urlsList;
	}

	public String getCountxt() {
		return countxt;
	}

	public void setCountxt(String countxt) {
		this.countxt = countxt;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	@Override
	public String toString() {
		return "HttpBody [url=" + url + ", urlsList=" + urlsList + ", countxt=" + countxt + ", date=" + date + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((countxt == null) ? 0 : countxt.hashCode());
		result = prime * result + ((date == null) ? 0 : date.hashCode());
		result = prime * result + ((url == null) ? 0 : url.hashCode());
		result = prime * result + ((urlsList == null) ? 0 : urlsList.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		HttpBody other = (HttpBody) obj;
		if (countxt == null) {
			if (other.countxt != null)
				return false;
		} else if (!countxt.equals(other.countxt))
			return false;
		if (date == null) {
			if (other.date != null)
				return false;
		} else if (!date.equals(other.date))
			return false;
		if (url == null) {
			if (other.url != null)
				return false;
		} else if (!url.equals(other.url))
			return false;
		if (urlsList == null) {
			if (other.urlsList != null)
				return false;
		} else if (!urlsList.equals(other.urlsList))
			return false;
		return true;
	}

}
